<?php $this->resetDataSource(); ?>
<table <?php echo $this->getAttributeHtml() ?>>
<thead>
<tr>
<?php if($this->getIndexable()): ?>
<th class="index">#</th>
<?php endif; ?>
<?php if($this->getAllowCheck()): ?>
<th class="checkbox first">#</th>
<?php endif; ?>
<?php
foreach($this->getColumns() as $column):
    echo '<th align="'.$column->getAlign().'" width="'.$column->getWidth().'">'.$column->getHead()->toHtml().'</th>';
endforeach;
?>
</tr>
<?php if($this->getAllowFilter()){ ?>
<tr class="filter">
<?php if($this->getAllowCheck()): ?>
<th></th>
<?php endif; ?>
<?php if($this->getIndexable()): ?>
<th></th>
<?php endif; ?>
<?php foreach($this->getColumns() as $column): ?>
<th style="text-align:<?php echo $column->getAlign(); ?>">
<?php
$filter = $column->getFilter();
if($filter){
    echo $filter->toHtml();
}
?>
</th>
<?php endforeach;?>
</tr>
<?php } ?>
</thead>
<tbody>
<?php
while(($row = $this->nextRow()) !== FALSE):
    $rowClass = $this->isOddRow()? 'odd': 'even';
    $rowClass .= $this->isFirstRow()? ' first': '';
    $rowClass .= $this->isLastRow()? ' last': '';
?>
<tr id="row<?php echo $row[$this->getPrimaryKey()]; ?>" class="<?php echo $rowClass?>">
    <?php if($this->getIndexable()): ?>
    <td class="index"><span><?php echo $this->getRowIndex() + 1;?></span></td>
    <?php endif; ?>
    <?php if($this->getAllowCheck()): ?>
    <td class="first checkbox">
        <input id="row_check<?php echo $row[$this->getPrimaryKey()]; ?>" class="row-check" type="checkbox" value="<?php echo $row[$this->getPrimaryKey()]; ?>" name="ids[]"/>
    </td>
    <?php endif; ?>
    <?php
    foreach($this->getColumns() as $column):
        echo '<td align="'.$column->getCell()->getAlign().'" field="'.$column->getName().'">'.$column->getCell()->toHtml().'</td>';
    endforeach;
    ?>
</tr>
<?php endwhile; ?>
</tbody>
</table>